package com.xd.springaiagent.controller;

import com.xd.springaiagent.agent.Manus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;

@RequestMapping("/maus")
@RestController
public class MausAgent {

    @Autowired
    private Manus manus;

    @GetMapping(value = "/run", produces = "text/html;charset=UTF-8")
    public SseEmitter run(@RequestParam String request) {
        SseEmitter emitter = new SseEmitter(-1L); // 无超时
        manus.run(request, emitter); // 直接调用，减少控制器逻辑
        return emitter;
    }
}
